/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.dataImport.r9.bean;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.yunhoo.sys.db.util.ConnectRemoteDB;
import com.yunhoo.sys.db.util.IbatisTemplate;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

public class UpdateDataSource {

    private ConnectRemoteDB dbParam = new ConnectRemoteDB("R9");

    public void updateRemoteDataSource(String orgCode, Integer iyear) throws SQLException {
        System.out.println("updateRemoteDataSource from " + dbParam.getSERVER() + " " + dbParam.getDB());
        SqlMapClient client = IbatisTemplate.getSqlMapClient();
        Map map = new HashMap();
        map.put("SERVER", dbParam.getSERVER());
        map.put("DB", dbParam.getDB());
        map.put("UID", dbParam.getUID());
        map.put("PWD", dbParam.getPWD());
        map.put("orgCode", orgCode);
        map.put("iyear", iyear);
//            map.put("SERVER", "192.168.0.102");
//            map.put("DB", "ceatest");
//            map.put("UID", "sa");
//            map.put("PWD", "cw");
        client.startTransaction();
        client.startBatch();
        client.insert("r9DataImport.updateRemoteDataSourceOfR9", map);//更新 支出数据 数据源
        client.insert("r9DataImport.updateR9FinCostDataConfig", map);//更新 预算项目 配置源 表 数据
        client.insert("r9DataImport.updateR9EcoCostDataConfig", map);//更新 经济科目 配置源 表 数据
        client.insert("r9DataImport.updateR9PubCostKm", map);//更新 经济科目 配置源 表 数据   
        client.insert("r9DataImport.updatePzxx", map);//凭证信息      
        client.executeBatch();
        client.commitTransaction();
        client.endTransaction();
    }
}
